package o;

import com.google.android.exoplayer2.text.SubtitleDecoderException;
import com.google.android.exoplayer2.text.ttml.TtmlStyle;
import com.huawei.hms.common.data.DataBufferSafeParcelable;
import com.huawei.hwid.core.constants.HwAccountConstants;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.util.ArrayDeque;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import org.xmlpull.v1.XmlPullParserFactory;

public final class akh extends ajh {
    private static final c ʻ = new c(30.0f, 1, 1);
    private static final b ʼ = new b(32, 15);
    private static final Pattern ˊ = Pattern.compile("^([0-9][0-9]+):([0-9][0-9]):([0-9][0-9])(?:(\\.[0-9]+)|:([0-9][0-9])(?:\\.([0-9]+))?)?$");
    private static final Pattern ˋ = Pattern.compile("^(\\d+\\.?\\d*?)% (\\d+\\.?\\d*?)%$");
    private static final Pattern ˎ = Pattern.compile("^([0-9]+(?:\\.[0-9]+)?)(h|m|s|ms|f|t)$");
    private static final Pattern ˏ = Pattern.compile("^(([0-9]*.)?[0-9]+)(px|em|%)$");
    private static final Pattern ॱ = Pattern.compile("^(\\d+\\.?\\d*?)px (\\d+\\.?\\d*?)px$");
    private static final Pattern ᐝ = Pattern.compile("^(\\d+) (\\d+)$");
    private final XmlPullParserFactory ʽ;

    static final class a {
        final int ˎ;
        final int ॱ;

        a(int i, int i2) {
            this.ॱ = i;
            this.ˎ = i2;
        }
    }

    static final class b {
        final int ˊ;
        final int ˏ;

        b(int i, int i2) {
            this.ˊ = i;
            this.ˏ = i2;
        }
    }

    static final class c {
        final int ˊ;
        final int ˋ;
        final float ˏ;

        c(float f, int i, int i2) {
            this.ˏ = f;
            this.ˋ = i;
            this.ˊ = i2;
        }
    }

    protected /* synthetic */ aji ˎ(byte[] bArr, int i, boolean z) throws SubtitleDecoderException {
        return ˊ(bArr, i, z);
    }

    public akh() {
        super("TtmlDecoder");
        try {
            this.ʽ = XmlPullParserFactory.newInstance();
            this.ʽ.setNamespaceAware(true);
        } catch (Throwable e) {
            throw new RuntimeException("Couldn't create XmlPullParserFactory instance", e);
        }
    }

    protected akl ˊ(byte[] bArr, int i, boolean z) throws SubtitleDecoderException {
        try {
            XmlPullParser newPullParser = this.ʽ.newPullParser();
            Map hashMap = new HashMap();
            Map hashMap2 = new HashMap();
            Map hashMap3 = new HashMap();
            hashMap2.put("", new akd(null));
            newPullParser.setInput(new ByteArrayInputStream(bArr, 0, i), null);
            akl o_akl = null;
            ArrayDeque arrayDeque = new ArrayDeque();
            int i2 = 0;
            int eventType = newPullParser.getEventType();
            c cVar = ʻ;
            b bVar = ʼ;
            a aVar = null;
            for (int i3 = eventType; i3 != 1; i3 = newPullParser.getEventType()) {
                ake o_ake = (ake) arrayDeque.peek();
                if (i2 == 0) {
                    akl o_akl2;
                    c cVar2;
                    int i4;
                    String name = newPullParser.getName();
                    if (i3 == 2) {
                        if ("tt".equals(name)) {
                            cVar = ˏ(newPullParser);
                            bVar = ˎ(newPullParser, ʼ);
                            aVar = ˎ(newPullParser);
                        }
                        int i5;
                        if (!ˋ(name)) {
                            amz.ॱ("TtmlDecoder", "Ignoring unsupported tag: " + newPullParser.getName());
                            eventType = i2 + 1;
                            o_akl2 = o_akl;
                            i5 = eventType;
                            cVar2 = cVar;
                            i4 = i5;
                        } else if ("head".equals(name)) {
                            ˊ(newPullParser, hashMap, bVar, aVar, hashMap2, hashMap3);
                            cVar2 = cVar;
                            i4 = i2;
                            o_akl2 = o_akl;
                        } else {
                            try {
                                ake ˊ = ˊ(newPullParser, o_ake, hashMap2, cVar);
                                arrayDeque.push(ˊ);
                                if (o_ake != null) {
                                    o_ake.ˎ(ˊ);
                                }
                                cVar2 = cVar;
                                i4 = i2;
                                o_akl2 = o_akl;
                            } catch (Throwable e) {
                                amz.ˋ("TtmlDecoder", "Suppressing parser error", e);
                                eventType = i2 + 1;
                                o_akl2 = o_akl;
                                i5 = eventType;
                                cVar2 = cVar;
                                i4 = i5;
                            }
                        }
                    } else if (i3 == 4) {
                        o_ake.ˎ(ake.ॱ(newPullParser.getText()));
                        cVar2 = cVar;
                        i4 = i2;
                        o_akl2 = o_akl;
                    } else if (i3 == 3) {
                        akl o_akl3;
                        if (newPullParser.getName().equals("tt")) {
                            o_akl3 = new akl((ake) arrayDeque.peek(), hashMap, hashMap2, hashMap3);
                        } else {
                            o_akl3 = o_akl;
                        }
                        arrayDeque.pop();
                        c cVar3 = cVar;
                        i4 = i2;
                        o_akl2 = o_akl3;
                        cVar2 = cVar3;
                    } else {
                        cVar2 = cVar;
                        i4 = i2;
                        o_akl2 = o_akl;
                    }
                    o_akl = o_akl2;
                    i2 = i4;
                    cVar = cVar2;
                } else if (i3 == 2) {
                    i2++;
                } else if (i3 == 3) {
                    i2--;
                }
                newPullParser.next();
            }
            return o_akl;
        } catch (Throwable e2) {
            throw new SubtitleDecoderException("Unable to decode source", e2);
        } catch (Throwable e22) {
            throw new IllegalStateException("Unexpected error when reading input.", e22);
        }
    }

    private c ˏ(XmlPullParser xmlPullParser) throws SubtitleDecoderException {
        int i = 30;
        String attributeValue = xmlPullParser.getAttributeValue("http://www.w3.org/ns/ttml#parameter", "frameRate");
        if (attributeValue != null) {
            i = Integer.parseInt(attributeValue);
        }
        float f = 1.0f;
        String attributeValue2 = xmlPullParser.getAttributeValue("http://www.w3.org/ns/ttml#parameter", "frameRateMultiplier");
        if (attributeValue2 != null) {
            String[] ˎ = anr.ˎ(attributeValue2, HwAccountConstants.BLANK);
            if (ˎ.length != 2) {
                throw new SubtitleDecoderException("frameRateMultiplier doesn't have 2 parts");
            }
            f = ((float) Integer.parseInt(ˎ[0])) / ((float) Integer.parseInt(ˎ[1]));
        }
        int i2 = ʻ.ˋ;
        String attributeValue3 = xmlPullParser.getAttributeValue("http://www.w3.org/ns/ttml#parameter", "subFrameRate");
        if (attributeValue3 != null) {
            i2 = Integer.parseInt(attributeValue3);
        }
        int i3 = ʻ.ˊ;
        String attributeValue4 = xmlPullParser.getAttributeValue("http://www.w3.org/ns/ttml#parameter", "tickRate");
        if (attributeValue4 != null) {
            i3 = Integer.parseInt(attributeValue4);
        }
        return new c(((float) i) * f, i2, i3);
    }

    private b ˎ(XmlPullParser xmlPullParser, b bVar) throws SubtitleDecoderException {
        String attributeValue = xmlPullParser.getAttributeValue("http://www.w3.org/ns/ttml#parameter", "cellResolution");
        if (attributeValue == null) {
            return bVar;
        }
        Matcher matcher = ᐝ.matcher(attributeValue);
        if (matcher.matches()) {
            try {
                int parseInt = Integer.parseInt(matcher.group(1));
                int parseInt2 = Integer.parseInt(matcher.group(2));
                if (parseInt != 0 && parseInt2 != 0) {
                    return new b(parseInt, parseInt2);
                }
                throw new SubtitleDecoderException("Invalid cell resolution " + parseInt + HwAccountConstants.BLANK + parseInt2);
            } catch (NumberFormatException e) {
                amz.ˏ("TtmlDecoder", "Ignoring malformed cell resolution: " + attributeValue);
                return bVar;
            }
        }
        amz.ˏ("TtmlDecoder", "Ignoring malformed cell resolution: " + attributeValue);
        return bVar;
    }

    private a ˎ(XmlPullParser xmlPullParser) {
        String ˏ = ans.ˏ(xmlPullParser, "extent");
        if (ˏ == null) {
            return null;
        }
        Matcher matcher = ॱ.matcher(ˏ);
        if (matcher.matches()) {
            try {
                return new a(Integer.parseInt(matcher.group(1)), Integer.parseInt(matcher.group(2)));
            } catch (NumberFormatException e) {
                amz.ˏ("TtmlDecoder", "Ignoring malformed tts extent: " + ˏ);
                return null;
            }
        }
        amz.ˏ("TtmlDecoder", "Ignoring non-pixel tts extent: " + ˏ);
        return null;
    }

    private Map<String, TtmlStyle> ˊ(XmlPullParser xmlPullParser, Map<String, TtmlStyle> map, b bVar, a aVar, Map<String, akd> map2, Map<String, String> map3) throws IOException, XmlPullParserException {
        do {
            xmlPullParser.next();
            if (ans.ˊ(xmlPullParser, "style")) {
                String ˏ = ans.ˏ(xmlPullParser, "style");
                TtmlStyle ˎ = ˎ(xmlPullParser, new TtmlStyle());
                if (ˏ != null) {
                    for (Object obj : ˎ(ˏ)) {
                        ˎ.ॱ((TtmlStyle) map.get(obj));
                    }
                }
                if (ˎ.ʼ() != null) {
                    map.put(ˎ.ʼ(), ˎ);
                }
            } else if (ans.ˊ(xmlPullParser, "region")) {
                akd ˏ2 = ˏ(xmlPullParser, bVar, aVar);
                if (ˏ2 != null) {
                    map2.put(ˏ2.ॱ, ˏ2);
                }
            } else if (ans.ˊ(xmlPullParser, "metadata")) {
                ˏ(xmlPullParser, (Map) map3);
            }
        } while (!ans.ˋ(xmlPullParser, "head"));
        return map;
    }

    private void ˏ(XmlPullParser xmlPullParser, Map<String, String> map) throws IOException, XmlPullParserException {
        do {
            xmlPullParser.next();
            if (ans.ˊ(xmlPullParser, "image")) {
                String ˏ = ans.ˏ(xmlPullParser, "id");
                if (ˏ != null) {
                    map.put(ˏ, xmlPullParser.nextText());
                }
            }
        } while (!ans.ˋ(xmlPullParser, "metadata"));
    }

    private akd ˏ(XmlPullParser xmlPullParser, b bVar, a aVar) {
        int i = 2;
        akd o_akd = null;
        String ˏ = ans.ˏ(xmlPullParser, "id");
        if (ˏ == null) {
            return o_akd;
        }
        String ˏ2 = ans.ˏ(xmlPullParser, "origin");
        if (ˏ2 != null) {
            float parseFloat;
            float parseFloat2;
            Matcher matcher = ˋ.matcher(ˏ2);
            Matcher matcher2 = ॱ.matcher(ˏ2);
            if (matcher.matches()) {
                try {
                    parseFloat = Float.parseFloat(matcher.group(1)) / 100.0f;
                    parseFloat2 = Float.parseFloat(matcher.group(2)) / 100.0f;
                } catch (NumberFormatException e) {
                    amz.ˏ("TtmlDecoder", "Ignoring region with malformed origin: " + ˏ2);
                    return o_akd;
                }
            } else if (!matcher2.matches()) {
                amz.ˏ("TtmlDecoder", "Ignoring region with unsupported origin: " + ˏ2);
                return o_akd;
            } else if (aVar == null) {
                amz.ˏ("TtmlDecoder", "Ignoring region with missing tts:extent: " + ˏ2);
                return o_akd;
            } else {
                try {
                    int parseInt = Integer.parseInt(matcher2.group(1));
                    int parseInt2 = Integer.parseInt(matcher2.group(2));
                    parseFloat = ((float) parseInt) / ((float) aVar.ॱ);
                    parseFloat2 = ((float) parseInt2) / ((float) aVar.ˎ);
                } catch (NumberFormatException e2) {
                    amz.ˏ("TtmlDecoder", "Ignoring region with malformed origin: " + ˏ2);
                    return o_akd;
                }
            }
            CharSequence ˏ3 = ans.ˏ(xmlPullParser, "extent");
            if (ˏ3 != null) {
                float parseFloat3;
                float parseFloat4;
                Matcher matcher3 = ˋ.matcher(ˏ3);
                Matcher matcher4 = ॱ.matcher(ˏ3);
                if (matcher3.matches()) {
                    try {
                        parseFloat3 = Float.parseFloat(matcher3.group(1)) / 100.0f;
                        parseFloat4 = Float.parseFloat(matcher3.group(2)) / 100.0f;
                    } catch (NumberFormatException e3) {
                        amz.ˏ("TtmlDecoder", "Ignoring region with malformed extent: " + ˏ2);
                        return o_akd;
                    }
                } else if (!matcher4.matches()) {
                    amz.ˏ("TtmlDecoder", "Ignoring region with unsupported extent: " + ˏ2);
                    return o_akd;
                } else if (aVar == null) {
                    amz.ˏ("TtmlDecoder", "Ignoring region with missing tts:extent: " + ˏ2);
                    return o_akd;
                } else {
                    try {
                        int parseInt3 = Integer.parseInt(matcher4.group(1));
                        int parseInt4 = Integer.parseInt(matcher4.group(2));
                        parseFloat3 = ((float) parseInt3) / ((float) aVar.ॱ);
                        parseFloat4 = ((float) parseInt4) / ((float) aVar.ˎ);
                    } catch (NumberFormatException e4) {
                        amz.ˏ("TtmlDecoder", "Ignoring region with malformed extent: " + ˏ2);
                        return o_akd;
                    }
                }
                ˏ2 = ans.ˏ(xmlPullParser, "displayAlign");
                if (ˏ2 != null) {
                    String ˎ = anr.ˎ(ˏ2);
                    int i2 = -1;
                    switch (ˎ.hashCode()) {
                        case -1364013995:
                            if (ˎ.equals("center")) {
                                i2 = 0;
                                break;
                            }
                            break;
                        case 92734940:
                            if (ˎ.equals("after")) {
                                i2 = 1;
                                break;
                            }
                            break;
                    }
                    switch (i2) {
                        case 0:
                            i = 1;
                            parseFloat4 = parseFloat2 + (parseFloat4 / 2.0f);
                            break;
                        case 1:
                            parseFloat4 = parseFloat2 + parseFloat4;
                            break;
                    }
                }
                i = 0;
                parseFloat4 = parseFloat2;
                return new akd(ˏ, parseFloat, parseFloat4, 0, i, parseFloat3, 1, 1.0f / ((float) bVar.ˏ));
            }
            amz.ˏ("TtmlDecoder", "Ignoring region without an extent");
            return o_akd;
        }
        amz.ˏ("TtmlDecoder", "Ignoring region without an origin");
        return o_akd;
    }

    private String[] ˎ(String str) {
        String trim = str.trim();
        return trim.isEmpty() ? new String[0] : anr.ˎ(trim, "\\s+");
    }

    /* JADX WARNING: inconsistent code. */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    private com.google.android.exoplayer2.text.ttml.TtmlStyle ˎ(org.xmlpull.v1.XmlPullParser r13, com.google.android.exoplayer2.text.ttml.TtmlStyle r14) {
        /*
        r12 = this;
        r6 = 3;
        r5 = 2;
        r3 = -1;
        r4 = 1;
        r2 = 0;
        r8 = r13.getAttributeCount();
        r7 = r2;
        r0 = r14;
    L_0x000b:
        if (r7 >= r8) goto L_0x0211;
    L_0x000d:
        r9 = r13.getAttributeValue(r7);
        r1 = r13.getAttributeName(r7);
        r10 = r1.hashCode();
        switch(r10) {
            case -1550943582: goto L_0x0060;
            case -1224696685: goto L_0x0042;
            case -1065511464: goto L_0x006a;
            case -879295043: goto L_0x0074;
            case -734428249: goto L_0x0056;
            case 3355: goto L_0x0024;
            case 94842723: goto L_0x0038;
            case 365601008: goto L_0x004c;
            case 1287124693: goto L_0x002e;
            default: goto L_0x001c;
        };
    L_0x001c:
        r1 = r3;
    L_0x001d:
        switch(r1) {
            case 0: goto L_0x007f;
            case 1: goto L_0x0094;
            case 2: goto L_0x00bb;
            case 3: goto L_0x00e3;
            case 4: goto L_0x00ed;
            case 5: goto L_0x0111;
            case 6: goto L_0x0121;
            case 7: goto L_0x0131;
            case 8: goto L_0x01b0;
            default: goto L_0x0020;
        };
    L_0x0020:
        r1 = r7 + 1;
        r7 = r1;
        goto L_0x000b;
    L_0x0024:
        r10 = "id";
        r1 = r1.equals(r10);
        if (r1 == 0) goto L_0x001c;
    L_0x002c:
        r1 = r2;
        goto L_0x001d;
    L_0x002e:
        r10 = "backgroundColor";
        r1 = r1.equals(r10);
        if (r1 == 0) goto L_0x001c;
    L_0x0036:
        r1 = r4;
        goto L_0x001d;
    L_0x0038:
        r10 = "color";
        r1 = r1.equals(r10);
        if (r1 == 0) goto L_0x001c;
    L_0x0040:
        r1 = r5;
        goto L_0x001d;
    L_0x0042:
        r10 = "fontFamily";
        r1 = r1.equals(r10);
        if (r1 == 0) goto L_0x001c;
    L_0x004a:
        r1 = r6;
        goto L_0x001d;
    L_0x004c:
        r10 = "fontSize";
        r1 = r1.equals(r10);
        if (r1 == 0) goto L_0x001c;
    L_0x0054:
        r1 = 4;
        goto L_0x001d;
    L_0x0056:
        r10 = "fontWeight";
        r1 = r1.equals(r10);
        if (r1 == 0) goto L_0x001c;
    L_0x005e:
        r1 = 5;
        goto L_0x001d;
    L_0x0060:
        r10 = "fontStyle";
        r1 = r1.equals(r10);
        if (r1 == 0) goto L_0x001c;
    L_0x0068:
        r1 = 6;
        goto L_0x001d;
    L_0x006a:
        r10 = "textAlign";
        r1 = r1.equals(r10);
        if (r1 == 0) goto L_0x001c;
    L_0x0072:
        r1 = 7;
        goto L_0x001d;
    L_0x0074:
        r10 = "textDecoration";
        r1 = r1.equals(r10);
        if (r1 == 0) goto L_0x001c;
    L_0x007c:
        r1 = 8;
        goto L_0x001d;
    L_0x007f:
        r1 = "style";
        r10 = r13.getName();
        r1 = r1.equals(r10);
        if (r1 == 0) goto L_0x0020;
    L_0x008b:
        r0 = r12.ˊ(r0);
        r0 = r0.ˋ(r9);
        goto L_0x0020;
    L_0x0094:
        r0 = r12.ˊ(r0);
        r1 = o.amt.ˋ(r9);	 Catch:{ IllegalArgumentException -> 0x00a0 }
        r0.ˋ(r1);	 Catch:{ IllegalArgumentException -> 0x00a0 }
        goto L_0x0020;
    L_0x00a0:
        r1 = move-exception;
        r1 = "TtmlDecoder";
        r10 = new java.lang.StringBuilder;
        r10.<init>();
        r11 = "Failed parsing background value: ";
        r10 = r10.append(r11);
        r9 = r10.append(r9);
        r9 = r9.toString();
        o.amz.ˏ(r1, r9);
        goto L_0x0020;
    L_0x00bb:
        r0 = r12.ˊ(r0);
        r1 = o.amt.ˋ(r9);	 Catch:{ IllegalArgumentException -> 0x00c8 }
        r0.ˏ(r1);	 Catch:{ IllegalArgumentException -> 0x00c8 }
        goto L_0x0020;
    L_0x00c8:
        r1 = move-exception;
        r1 = "TtmlDecoder";
        r10 = new java.lang.StringBuilder;
        r10.<init>();
        r11 = "Failed parsing color value: ";
        r10 = r10.append(r11);
        r9 = r10.append(r9);
        r9 = r9.toString();
        o.amz.ˏ(r1, r9);
        goto L_0x0020;
    L_0x00e3:
        r0 = r12.ˊ(r0);
        r0 = r0.ˊ(r9);
        goto L_0x0020;
    L_0x00ed:
        r0 = r12.ˊ(r0);	 Catch:{ SubtitleDecoderException -> 0x00f6 }
        ˏ(r9, r0);	 Catch:{ SubtitleDecoderException -> 0x00f6 }
        goto L_0x0020;
    L_0x00f6:
        r1 = move-exception;
        r1 = "TtmlDecoder";
        r10 = new java.lang.StringBuilder;
        r10.<init>();
        r11 = "Failed parsing fontSize value: ";
        r10 = r10.append(r11);
        r9 = r10.append(r9);
        r9 = r9.toString();
        o.amz.ˏ(r1, r9);
        goto L_0x0020;
    L_0x0111:
        r0 = r12.ˊ(r0);
        r1 = "bold";
        r1 = r1.equalsIgnoreCase(r9);
        r0 = r0.ˊ(r1);
        goto L_0x0020;
    L_0x0121:
        r0 = r12.ˊ(r0);
        r1 = "italic";
        r1 = r1.equalsIgnoreCase(r9);
        r0 = r0.ˏ(r1);
        goto L_0x0020;
    L_0x0131:
        r1 = o.anr.ˎ(r9);
        r9 = r1.hashCode();
        switch(r9) {
            case -1364013995: goto L_0x0176;
            case 100571: goto L_0x016c;
            case 3317767: goto L_0x014e;
            case 108511772: goto L_0x0162;
            case 109757538: goto L_0x0158;
            default: goto L_0x013c;
        };
    L_0x013c:
        r1 = r3;
    L_0x013d:
        switch(r1) {
            case 0: goto L_0x0142;
            case 1: goto L_0x0180;
            case 2: goto L_0x018c;
            case 3: goto L_0x0198;
            case 4: goto L_0x01a4;
            default: goto L_0x0140;
        };
    L_0x0140:
        goto L_0x0020;
    L_0x0142:
        r0 = r12.ˊ(r0);
        r1 = android.text.Layout.Alignment.ALIGN_NORMAL;
        r0 = r0.ॱ(r1);
        goto L_0x0020;
    L_0x014e:
        r9 = "left";
        r1 = r1.equals(r9);
        if (r1 == 0) goto L_0x013c;
    L_0x0156:
        r1 = r2;
        goto L_0x013d;
    L_0x0158:
        r9 = "start";
        r1 = r1.equals(r9);
        if (r1 == 0) goto L_0x013c;
    L_0x0160:
        r1 = r4;
        goto L_0x013d;
    L_0x0162:
        r9 = "right";
        r1 = r1.equals(r9);
        if (r1 == 0) goto L_0x013c;
    L_0x016a:
        r1 = r5;
        goto L_0x013d;
    L_0x016c:
        r9 = "end";
        r1 = r1.equals(r9);
        if (r1 == 0) goto L_0x013c;
    L_0x0174:
        r1 = r6;
        goto L_0x013d;
    L_0x0176:
        r9 = "center";
        r1 = r1.equals(r9);
        if (r1 == 0) goto L_0x013c;
    L_0x017e:
        r1 = 4;
        goto L_0x013d;
    L_0x0180:
        r0 = r12.ˊ(r0);
        r1 = android.text.Layout.Alignment.ALIGN_NORMAL;
        r0 = r0.ॱ(r1);
        goto L_0x0020;
    L_0x018c:
        r0 = r12.ˊ(r0);
        r1 = android.text.Layout.Alignment.ALIGN_OPPOSITE;
        r0 = r0.ॱ(r1);
        goto L_0x0020;
    L_0x0198:
        r0 = r12.ˊ(r0);
        r1 = android.text.Layout.Alignment.ALIGN_OPPOSITE;
        r0 = r0.ॱ(r1);
        goto L_0x0020;
    L_0x01a4:
        r0 = r12.ˊ(r0);
        r1 = android.text.Layout.Alignment.ALIGN_CENTER;
        r0 = r0.ॱ(r1);
        goto L_0x0020;
    L_0x01b0:
        r1 = o.anr.ˎ(r9);
        r9 = r1.hashCode();
        switch(r9) {
            case -1461280213: goto L_0x01e9;
            case -1026963764: goto L_0x01df;
            case 913457136: goto L_0x01d5;
            case 1679736913: goto L_0x01cb;
            default: goto L_0x01bb;
        };
    L_0x01bb:
        r1 = r3;
    L_0x01bc:
        switch(r1) {
            case 0: goto L_0x01c1;
            case 1: goto L_0x01f3;
            case 2: goto L_0x01fd;
            case 3: goto L_0x0207;
            default: goto L_0x01bf;
        };
    L_0x01bf:
        goto L_0x0020;
    L_0x01c1:
        r0 = r12.ˊ(r0);
        r0 = r0.ˎ(r4);
        goto L_0x0020;
    L_0x01cb:
        r9 = "linethrough";
        r1 = r1.equals(r9);
        if (r1 == 0) goto L_0x01bb;
    L_0x01d3:
        r1 = r2;
        goto L_0x01bc;
    L_0x01d5:
        r9 = "nolinethrough";
        r1 = r1.equals(r9);
        if (r1 == 0) goto L_0x01bb;
    L_0x01dd:
        r1 = r4;
        goto L_0x01bc;
    L_0x01df:
        r9 = "underline";
        r1 = r1.equals(r9);
        if (r1 == 0) goto L_0x01bb;
    L_0x01e7:
        r1 = r5;
        goto L_0x01bc;
    L_0x01e9:
        r9 = "nounderline";
        r1 = r1.equals(r9);
        if (r1 == 0) goto L_0x01bb;
    L_0x01f1:
        r1 = r6;
        goto L_0x01bc;
    L_0x01f3:
        r0 = r12.ˊ(r0);
        r0 = r0.ˎ(r2);
        goto L_0x0020;
    L_0x01fd:
        r0 = r12.ˊ(r0);
        r0 = r0.ˋ(r4);
        goto L_0x0020;
    L_0x0207:
        r0 = r12.ˊ(r0);
        r0 = r0.ˋ(r2);
        goto L_0x0020;
    L_0x0211:
        return r0;
        */
        throw new UnsupportedOperationException("Method not decompiled: o.akh.ˎ(org.xmlpull.v1.XmlPullParser, com.google.android.exoplayer2.text.ttml.TtmlStyle):com.google.android.exoplayer2.text.ttml.TtmlStyle");
    }

    private TtmlStyle ˊ(TtmlStyle ttmlStyle) {
        return ttmlStyle == null ? new TtmlStyle() : ttmlStyle;
    }

    /* JADX WARNING: inconsistent code. */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    private o.ake ˊ(org.xmlpull.v1.XmlPullParser r21, o.ake r22, java.util.Map<java.lang.String, o.akd> r23, o.akh.c r24) throws com.google.android.exoplayer2.text.SubtitleDecoderException {
        /*
        r20 = this;
        r12 = -9223372036854775807; // 0x8000000000000001 float:1.4E-45 double:-4.9E-324;
        r6 = -9223372036854775807; // 0x8000000000000001 float:1.4E-45 double:-4.9E-324;
        r4 = -9223372036854775807; // 0x8000000000000001 float:1.4E-45 double:-4.9E-324;
        r10 = "";
        r11 = 0;
        r9 = 0;
        r15 = r21.getAttributeCount();
        r2 = 0;
        r0 = r20;
        r1 = r21;
        r8 = r0.ˎ(r1, r2);
        r2 = 0;
        r14 = r2;
    L_0x0022:
        if (r14 >= r15) goto L_0x00d1;
    L_0x0024:
        r0 = r21;
        r16 = r0.getAttributeName(r14);
        r0 = r21;
        r2 = r0.getAttributeValue(r14);
        r3 = -1;
        r17 = r16.hashCode();
        switch(r17) {
            case -934795532: goto L_0x006d;
            case 99841: goto L_0x0059;
            case 100571: goto L_0x004f;
            case 93616297: goto L_0x0045;
            case 109780401: goto L_0x0063;
            case 1292595405: goto L_0x0077;
            default: goto L_0x0038;
        };
    L_0x0038:
        switch(r3) {
            case 0: goto L_0x0081;
            case 1: goto L_0x008e;
            case 2: goto L_0x0097;
            case 3: goto L_0x00a4;
            case 4: goto L_0x00b2;
            case 5: goto L_0x00bf;
            default: goto L_0x003b;
        };
    L_0x003b:
        r2 = r4;
        r4 = r6;
        r6 = r12;
    L_0x003e:
        r12 = r14 + 1;
        r14 = r12;
        r12 = r6;
        r6 = r4;
        r4 = r2;
        goto L_0x0022;
    L_0x0045:
        r17 = "begin";
        r16 = r16.equals(r17);
        if (r16 == 0) goto L_0x0038;
    L_0x004d:
        r3 = 0;
        goto L_0x0038;
    L_0x004f:
        r17 = "end";
        r16 = r16.equals(r17);
        if (r16 == 0) goto L_0x0038;
    L_0x0057:
        r3 = 1;
        goto L_0x0038;
    L_0x0059:
        r17 = "dur";
        r16 = r16.equals(r17);
        if (r16 == 0) goto L_0x0038;
    L_0x0061:
        r3 = 2;
        goto L_0x0038;
    L_0x0063:
        r17 = "style";
        r16 = r16.equals(r17);
        if (r16 == 0) goto L_0x0038;
    L_0x006b:
        r3 = 3;
        goto L_0x0038;
    L_0x006d:
        r17 = "region";
        r16 = r16.equals(r17);
        if (r16 == 0) goto L_0x0038;
    L_0x0075:
        r3 = 4;
        goto L_0x0038;
    L_0x0077:
        r17 = "backgroundImage";
        r16 = r16.equals(r17);
        if (r16 == 0) goto L_0x0038;
    L_0x007f:
        r3 = 5;
        goto L_0x0038;
    L_0x0081:
        r0 = r24;
        r2 = ˋ(r2, r0);
        r6 = r12;
        r18 = r2;
        r2 = r4;
        r4 = r18;
        goto L_0x003e;
    L_0x008e:
        r0 = r24;
        r2 = ˋ(r2, r0);
        r4 = r6;
        r6 = r12;
        goto L_0x003e;
    L_0x0097:
        r0 = r24;
        r2 = ˋ(r2, r0);
        r18 = r4;
        r4 = r6;
        r6 = r2;
        r2 = r18;
        goto L_0x003e;
    L_0x00a4:
        r0 = r20;
        r2 = r0.ˎ(r2);
        r3 = r2.length;
        if (r3 <= 0) goto L_0x003b;
    L_0x00ad:
        r9 = r2;
        r2 = r4;
        r4 = r6;
        r6 = r12;
        goto L_0x003e;
    L_0x00b2:
        r0 = r23;
        r3 = r0.containsKey(r2);
        if (r3 == 0) goto L_0x003b;
    L_0x00ba:
        r10 = r2;
        r2 = r4;
        r4 = r6;
        r6 = r12;
        goto L_0x003e;
    L_0x00bf:
        r3 = "#";
        r3 = r2.startsWith(r3);
        if (r3 == 0) goto L_0x003b;
    L_0x00c7:
        r3 = 1;
        r11 = r2.substring(r3);
        r2 = r4;
        r4 = r6;
        r6 = r12;
        goto L_0x003e;
    L_0x00d1:
        if (r22 == 0) goto L_0x0132;
    L_0x00d3:
        r0 = r22;
        r2 = r0.ˊ;
        r14 = -9223372036854775807; // 0x8000000000000001 float:1.4E-45 double:-4.9E-324;
        r2 = (r2 > r14 ? 1 : (r2 == r14 ? 0 : -1));
        if (r2 == 0) goto L_0x0132;
    L_0x00e0:
        r2 = -9223372036854775807; // 0x8000000000000001 float:1.4E-45 double:-4.9E-324;
        r2 = (r6 > r2 ? 1 : (r6 == r2 ? 0 : -1));
        if (r2 == 0) goto L_0x00ee;
    L_0x00e9:
        r0 = r22;
        r2 = r0.ˊ;
        r6 = r6 + r2;
    L_0x00ee:
        r2 = -9223372036854775807; // 0x8000000000000001 float:1.4E-45 double:-4.9E-324;
        r2 = (r4 > r2 ? 1 : (r4 == r2 ? 0 : -1));
        if (r2 == 0) goto L_0x0132;
    L_0x00f7:
        r0 = r22;
        r2 = r0.ˊ;
        r4 = r4 + r2;
        r18 = r4;
        r4 = r6;
        r6 = r18;
    L_0x0101:
        r2 = -9223372036854775807; // 0x8000000000000001 float:1.4E-45 double:-4.9E-324;
        r2 = (r6 > r2 ? 1 : (r6 == r2 ? 0 : -1));
        if (r2 != 0) goto L_0x0115;
    L_0x010a:
        r2 = -9223372036854775807; // 0x8000000000000001 float:1.4E-45 double:-4.9E-324;
        r2 = (r12 > r2 ? 1 : (r12 == r2 ? 0 : -1));
        if (r2 == 0) goto L_0x011e;
    L_0x0113:
        r6 = r4 + r12;
    L_0x0115:
        r3 = r21.getName();
        r2 = o.ake.ˊ(r3, r4, r6, r8, r9, r10, r11);
        return r2;
    L_0x011e:
        if (r22 == 0) goto L_0x0115;
    L_0x0120:
        r0 = r22;
        r2 = r0.ॱ;
        r12 = -9223372036854775807; // 0x8000000000000001 float:1.4E-45 double:-4.9E-324;
        r2 = (r2 > r12 ? 1 : (r2 == r12 ? 0 : -1));
        if (r2 == 0) goto L_0x0115;
    L_0x012d:
        r0 = r22;
        r6 = r0.ॱ;
        goto L_0x0115;
    L_0x0132:
        r18 = r4;
        r4 = r6;
        r6 = r18;
        goto L_0x0101;
        */
        throw new UnsupportedOperationException("Method not decompiled: o.akh.ˊ(org.xmlpull.v1.XmlPullParser, o.ake, java.util.Map, o.akh$c):o.ake");
    }

    private static boolean ˋ(String str) {
        if (str.equals("tt") || str.equals("head") || str.equals("body") || str.equals("div") || str.equals("p") || str.equals("span") || str.equals("br") || str.equals("style") || str.equals("styling") || str.equals("layout") || str.equals("region") || str.equals("metadata") || str.equals("image") || str.equals(DataBufferSafeParcelable.DATA_FIELD) || str.equals("information")) {
            return true;
        }
        return false;
    }

    private static void ˏ(String str, TtmlStyle ttmlStyle) throws SubtitleDecoderException {
        Matcher matcher;
        String[] ˎ = anr.ˎ(str, "\\s+");
        if (ˎ.length == 1) {
            matcher = ˏ.matcher(str);
        } else if (ˎ.length == 2) {
            matcher = ˏ.matcher(ˎ[1]);
            amz.ˏ("TtmlDecoder", "Multiple values in fontSize attribute. Picking the second value for vertical font size and ignoring the first.");
        } else {
            throw new SubtitleDecoderException("Invalid number of entries for fontSize: " + ˎ.length + ".");
        }
        if (matcher.matches()) {
            String group = matcher.group(3);
            int i = -1;
            switch (group.hashCode()) {
                case 37:
                    if (group.equals("%")) {
                        i = 2;
                        break;
                    }
                    break;
                case 3240:
                    if (group.equals("em")) {
                        i = 1;
                        break;
                    }
                    break;
                case 3592:
                    if (group.equals("px")) {
                        i = 0;
                        break;
                    }
                    break;
            }
            switch (i) {
                case 0:
                    ttmlStyle.ˊ(1);
                    break;
                case 1:
                    ttmlStyle.ˊ(2);
                    break;
                case 2:
                    ttmlStyle.ˊ(3);
                    break;
                default:
                    throw new SubtitleDecoderException("Invalid unit for fontSize: '" + group + "'.");
            }
            ttmlStyle.ˎ(Float.valueOf(matcher.group(1)).floatValue());
            return;
        }
        throw new SubtitleDecoderException("Invalid expression for fontSize: '" + str + "'.");
    }

    private static long ˋ(String str, c cVar) throws SubtitleDecoderException {
        double d = 0.0d;
        Matcher matcher = ˊ.matcher(str);
        double parseLong;
        if (matcher.matches()) {
            double parseLong2 = ((double) Long.parseLong(matcher.group(3))) + (((double) (Long.parseLong(matcher.group(1)) * 3600)) + ((double) (Long.parseLong(matcher.group(2)) * 60)));
            String group = matcher.group(4);
            parseLong2 += group != null ? Double.parseDouble(group) : 0.0d;
            group = matcher.group(5);
            if (group != null) {
                parseLong = (double) (((float) Long.parseLong(group)) / cVar.ˏ);
            } else {
                parseLong = 0.0d;
            }
            parseLong += parseLong2;
            String group2 = matcher.group(6);
            if (group2 != null) {
                d = (((double) Long.parseLong(group2)) / ((double) cVar.ˋ)) / ((double) cVar.ˏ);
            }
            return (long) ((parseLong + d) * 1000000.0d);
        }
        Matcher matcher2 = ˎ.matcher(str);
        if (matcher2.matches()) {
            parseLong = Double.parseDouble(matcher2.group(1));
            String group3 = matcher2.group(2);
            int i = -1;
            switch (group3.hashCode()) {
                case 102:
                    if (group3.equals("f")) {
                        i = 4;
                        break;
                    }
                    break;
                case 104:
                    if (group3.equals("h")) {
                        i = 0;
                        break;
                    }
                    break;
                case 109:
                    if (group3.equals("m")) {
                        i = 1;
                        break;
                    }
                    break;
                case 115:
                    if (group3.equals("s")) {
                        i = 2;
                        break;
                    }
                    break;
                case 116:
                    if (group3.equals("t")) {
                        i = 5;
                        break;
                    }
                    break;
                case 3494:
                    if (group3.equals("ms")) {
                        i = 3;
                        break;
                    }
                    break;
            }
            switch (i) {
                case 0:
                    parseLong *= 3600.0d;
                    break;
                case 1:
                    parseLong *= 60.0d;
                    break;
                case 3:
                    parseLong /= 1000.0d;
                    break;
                case 4:
                    parseLong /= (double) cVar.ˏ;
                    break;
                case 5:
                    parseLong /= (double) cVar.ˊ;
                    break;
            }
            return (long) (parseLong * 1000000.0d);
        }
        throw new SubtitleDecoderException("Malformed time expression: " + str);
    }
}
